﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace DHQGHN.PM0.Models.Admin
{
    public class MenuInRoleModel
    {
        #region Property of Model
        [Range(1, Int64.MaxValue, ErrorMessage = "Bạn cần chọn ứng dụng")]
        [Display(Name = "Ứng dụng")]
        public int AppID { get; set; }
        public string AppName { get; set; }

        [Range(1, Int64.MaxValue, ErrorMessage = "Bạn cần chọn chức năng")]
        [Display(Name = "Chức năng")]
        public int MenuID { get; set; }

        public int MenuInRoleID { get; set; }

        public int IsActive { get; set; }

        [Range(1, Int64.MaxValue, ErrorMessage = "Bạn cần chọn vai trò")]
        [Display(Name = "Vai trò")]
        public int RoleID { get; set; }

        public int RecordCount { get; set; }

        [StringLength(150, ErrorMessage = "Độ dài tối đa là 150 ký tự")]
        [Display(Name = "Mô tả")]
        public string Descriptions { get; set; }
        public string MenuName { get; set; }
        public string MenuCode { get; set; }
        public string RoleName { get; set; }
        #endregion


        #region Field list from database
        public const string FIELD_APP_NAME = "AppName";
        public const string FIELD_ID = "MenuInRoleId";
        public const string FIELD_NAME = "NAME";
        public const string FIELD_CODE = "CODE";
        public const string FIELD_DESCRIPTIONS = "DESCRIPTIONS";
        public const string FIELD_ROLE_NAME = "RoleName";
        public const string FIELD_MENU_NAME = "MenuName";
        public const string FIELD_MENU_CODE = "MenuCode";
        public const string FIELD_RECORD_COUNT = "RecordCount";
        #endregion

        #region Constructor of model
        public MenuInRoleModel() { }

        public MenuInRoleModel(DAL.Models.Admin.MenuInRoleModel model)
        {
            AppID = model.AppID;
            AppName = model.AppName;
            Descriptions = model.Descriptions;
            MenuCode = model.MenuCode;
            MenuName = model.MenuName;
            MenuID = model.MenuID;
            MenuInRoleID = model.MenuInRoleID;
            RecordCount = model.RecordCount;
            RoleID = model.RoleID;
            RoleName = model.RoleName;
        }
        #endregion

        // Convert from model of PM0 project to model of DAL project
        internal DAL.Models.Admin.MenuInRoleModel toDALModel()
        {
            DAL.Models.Admin.MenuInRoleModel model = new DAL.Models.Admin.MenuInRoleModel
            {
                AppName = AppName,
                AppID = AppID,
                Descriptions = Descriptions,
                MenuCode = MenuCode,
                MenuID = MenuID,
                MenuName = MenuName,
                MenuInRoleID = MenuInRoleID,
                RoleName = RoleName,
                RoleID = RoleID,
                RecordCount = RecordCount
            };
            return model;
        }
    }
}